package cn.itsource.crm.web.controller;

import cn.itsource.crm.domain.SystemDictionaryItem;
import cn.itsource.crm.service.ISystemDictionaryItemService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/systemDictionaryItem")
@CrossOrigin//解决跨域问题
public class SystemDictionaryItemController {

    @Autowired
    private ISystemDictionaryItemService systemDictionaryItemService;

    /**
     * 查询所有数据信息
     * @return
     */
    @RequestMapping(value = "/list",method = RequestMethod.PATCH)//批量查询用PATCH
    @ResponseBody
    @ApiOperation(value = "list查询所有方法",notes = "查询所有部门信息")
    //HTTP响应整体描述
    @ApiResponses({
            //HTTP响应其中1个描述
            @ApiResponse(code = 200,message = "成功"),
            @ApiResponse(code = 500,message = "网络错误，请稍后")
    })
    public List<SystemDictionaryItem> list(){
        System.out.println("patch请求，获取所有数据");
        return systemDictionaryItemService.findAll();
    }


    @RequestMapping(value = "/item",method = RequestMethod.PATCH)//批量查询用PATCH
    @ResponseBody
    public List<SystemDictionaryItem> item(){
        return systemDictionaryItemService.findItem();
    }


    @RequestMapping(value = "/planType",method = RequestMethod.PATCH)//批量查询用PATCH
    @ResponseBody
    public List<SystemDictionaryItem> planType(){
        return systemDictionaryItemService.findPlanType();
    }
}
